Skip to content

Test the pygame UI input primitives via injected events#98

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/pygame-input-tests
Jun 13, 2026
Merged

Test the pygame UI input primitives via injected events#98
dmccoystephenson merged 1 commit into
mainfrom
feature/pygame-input-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B test-expansion (continued): the pygame interactive input primitives had zero coverage. This injects events through a patched pygame.event.get (with the per-frame display.flip/Clock stubbed) to exercise their key handling.

  • showDialogue: a keypress ends the wait and resets the prompt to "What would you like to do?"
  • timedKeyPress: returns a non-negative float reaction time after a keypress.
  • promptForText: accumulates typed characters, honors Backspace, and submits on Enter ("h","i",Enter"hi"; "a","b",Backspace,Enter"a").

Characterization only — no production code changed; runs headless under dummy SDL.

Test plan

  • SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest — 218 passed (4 new)

🤖 Generated with Claude Code

showDialogue, timedKeyPress, and promptForText drive pygame event loops and had
no coverage — only the resize/font helpers were tested. A regression in their
key handling (e.g. backspace or Enter-to-submit) would go unnoticed.

Adds tests that inject events through a patched pygame.event.get (with the
per-frame flip/clock stubbed): a keypress dismisses showDialogue and resets the
prompt, timedKeyPress returns a non-negative reaction, and promptForText
accumulates typed characters and honors backspace before Enter submits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@dmccoystephenson dmccoystephenson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review:

  • Scope: PASS — appends to the pygame test file; characterization only, no prod change.
  • Tests-new: PASS — showDialogue/timedKeyPress/promptForText key handling (incl. backspace + Enter-submit) were previously uncovered.
  • Headless-pygame: PASS — events injected via patched event.get; flip/Clock stubbed; CI green (218).
  • Deterministic: PASS — no unseeded random; events are explicit.

@dmccoystephenson dmccoystephenson merged commit 2c15d3d into main Jun 13, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the feature/pygame-input-tests branch June 13, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant